home *** CD-ROM | disk | FTP | other *** search
/ C++ für Kids / C++ for kids.iso / Buch / Kohle2.cpp < prev    next >
C/C++ Source or Header  |  1998-12-14  |  1KB  |  52 lines

  1. //---------------------------------------------------------------------------
  2. #include <vcl\vcl.h>
  3. #pragma hdrstop
  4.  
  5. #include "Kohle2.h"
  6. //---------------------------------------------------------------------------
  7. #pragma resource "*.dfm"
  8. TForm1 *Form1;
  9. float Kapital, Zinsen, Prozent; int Nr, Laufzeit;
  10. //---------------------------------------------------------------------------
  11. __fastcall TForm1::TForm1(TComponent* Owner)
  12.     : TForm(Owner)
  13. {
  14. }
  15. //---------------------------------------------------------------------------
  16. void __fastcall TForm1::Button1Click(TObject *Sender)
  17. {
  18.   Nr++;
  19.   if (Nr == 1)
  20.   {
  21.     Kapital = StrToFloat (Edit1->Text);
  22.     Label1->Caption = "Wie hoch soll der Zinssatz sein?";
  23.     Edit1->Text = "";
  24.     Edit1->SetFocus ();
  25.   }
  26.   if (Nr == 2)
  27.   {
  28.     Prozent = StrToFloat (Edit1->Text);
  29.     Laufzeit = 0;
  30.     do
  31.     {
  32.       Zinsen = Kapital * Prozent / 100;
  33.       Kapital = Kapital + Zinsen;
  34.       if (Kapital < 1000000) Laufzeit++;
  35.     }
  36.     while (Kapital < 1000000);
  37.  
  38.     if (Laufzeit > 0)
  39.       Label1->Caption = "Dein Geld mu▀ "
  40.         + IntToStr (Laufzeit) + " Jahre auf der Bank braten";
  41.     else
  42.       Label1->Caption = "Willkommen im Club der MillionΣre!";
  43.   }
  44.  
  45. }
  46. //---------------------------------------------------------------------------
  47. void __fastcall TForm1::FormCreate(TObject *Sender)
  48. {
  49.   Nr = 0;
  50. }
  51. //---------------------------------------------------------------------------
  52.